<?php
if(Yii::app()->user->hasFlash('model')) {
	Yii::app()->user->flash('model', array('<div class="confirmation">', '</div>'));
	return;
}
?>

<div class="yiiForm">

<?php


$JFV=Yii::app()->jformvalidate;
$JFV->setOptions(array(
		'errorElement'=> 'div',
		'errorClass' => 'invalid',
        ));


echo $JFV->form(); 
?>

	<?php echo Html::errorSummary($model); ?>

	<div class="simple">
		<?php echo Html::activeLabel($model,title); ?>
		<?php echo $JFV->activeTextField($model,title); ?>
	</div>

	<div class="simple">
		<?php echo Html::activeLabel($model,description); ?>
		<?php echo $JFV->activeTextArea($model,description); ?>
	</div>

	<div class="simple">
		<?php echo Html::activeLabel($model,priority); ?>
		<?php echo CHtml::activeDropDownList($model,'priority',array('low'=>Yii::t('yii','Low'),'medium'=>Yii::t('yii','Medium'),'high'=>Yii::t('yii','High'))); ?>
	</div>

	<?php if (Yii::app()->user->hasAuth(Group::MODERATOR)): ?>

	<div class="simple">
		<?php echo Html::activeLabel($model,solved); ?>
		<?php echo CHtml::activeDropDownList($model,'solved',array('1'=>Yii::t('yii','Yes'),'2'=>Yii::t('yii','No'))); ?>
	</div>

	<div class="simple">
		<?php echo Html::activeLabel($model,comment); ?>
		<?php echo $JFV->activeTextArea($model,comment); ?>
	</div>

	<?php endif; ?>

	<div class="action">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Report' : 'Save',array('class'=>'submit')); ?>
	</div>

<?php echo $JFV->endForm(); ?>

</div><!-- form -->

<script type="text/javascript">
$("form").bind("submit", function() { return false; });

$('.submit').bind('click', function () {
  jQuery.ajax({
'type':'POST',
'url': jQuery(this).parents("form").attr("action"),
'cache':false,
'beforeSend': function(xhr) {xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")},
'data':jQuery(this).parents("form").serialize(),
'success':function(html){
jQuery("#content").html(html)}
});
  
  return false;
});

</script>
